<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
            list-style: none;
        }
        .table{
            width: 400px;
            overflow: hidden;
            margin: 50px auto; 
        }
        .table .item{
            float: left;
            width: 100px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            background-color: black;
            color:darkcyan;
        }

    </style>
</head>
<body>
    <div id="app">
            <h3>{{list}}</h3>
            <div class="table">
                <div class="tr">
                    <div class="item">编号</div>
                    <div class="item">用户名</div>
                    <div class="item">年龄</div>
                    <div class="item">操作</div>
                </div>

                <div class="tr" v-for="item in arr">
                    <div class="item">{{item.id}}</div>
                    <div class="item">{{item.username}}</div>
                    <div class="item">{{item.userage}}</div>
                    <div class="item" @click="delById(item.id)">删除</div>
                </div>
            </div>
    </div>
    
</body>
<script>
    new  Vue({
        el:"#app",
        data:{
            list:[1,2,3,4],
            arr:[{id:1,username:"leson",userage:18},{id:2,username:"lulu",userage:18},{id:3,username:"lili",userage:18}]
        },
        methods:{
            delById(id){  //根据id进行删除
                // alert(id);
                this.arr = this.arr.filter(item=>item.id!=id);
            }
        }
    })



</script>
</html>